The present invention relates to computer graphics, and more particularly to interactive graphics systems such as home video game platforms. Still more particularly this invention relates to a method and apparatus for performing environment mapped bump-mapping in a graphics system.
Many of us have seen films containing remarkably realistic dinosaurs, aliens, animated toys and other fanciful creatures. Such animations are made possible by computer graphics. Using such techniques, a computer graphics artist can specify how each object should look and how it should change in appearance over time, and a computer then models the objects and displays them on a display such as your television or a computer screen. The computer takes care of performing the many tasks required to make sure that each part of the displayed image is colored and shaped just right based on the position and orientation of each object in a scene, the direction in which light seems to strike each object, the surface texture of each object, and other factors.
Because computer graphics generation is complex, computer-generated three-dimensional graphics just a few years ago were mostly limited to expensive specialized flight simulators, high-end graphics workstations and supercomputers. The public saw some of the images generated by these computer systems in movies and expensive television advertisements, but most of us couldn""t actually interact with the computers doing the graphics generation. All this has changed with the availability of relatively inexpensive 3D graphics platforms such as, for example, the Nintendo 64(copyright) and various 3D graphics cards now available for personal computers. It is now possible to interact with exciting 3D animations and simulations on relatively inexpensive computer graphics systems in your home or office.
One problem graphics system designers confronted in the past was how to create realistic looking surface detail on a rendered object without resorting to explicit modeling of the desired details with polygons or other geometric primitives. Although surface details can be simulated, for example, using myriad small triangles with interpolated shading between vertices, as the desired detail becomes finer and more intricate, explicit modeling with triangles or other primitives places high demands on the graphics system and becomes less practical. An alternative technique pioneered by E. Catmull and refined by J. F. Blinn and M. E. Newell is to xe2x80x9cmapxe2x80x9d an image, either digitized or synthesized, onto a surface. (See xe2x80x9cA Subdivision Algorithm for Computer Display of Curved Surfacesxe2x80x9d by E. Catmull, Ph.D. Thesis, Report UTEC-CSc-74-133, Computer Science Department, University of Utah, Salt Lake City, Utah, December 1994 and xe2x80x9cTexture and Reflection in Computer Generated Imagesxe2x80x9d by J. F. Blinn and M. E. Newell, CACM, 19(10), October 1976, 452-457). This approach is known as texture mapping (or pattern mapping) and the image is called a texture map (or simply referred to as a texture). Alternatively, the texture map may be defined by a procedure rather than an image.
Typically, the texture map is defined within a 2D rectangular coordinate space and parameterized using a pair of orthogonal texture coordinates such, as for example, (u, v) or (s, t). Individual elements within the texture map are often called texels. At each rendered pixel, selected texels are used either to substitute for or to scale one or more material properties of the rendered object surface. This process is often referred to as texture mapping or xe2x80x9ctexturing.xe2x80x9d
Although most 3-D graphics rendering systems now include a texturing subsystem for retrieving textures from memory and mapping the textures onto a rendered object surface, another problem confronting graphics system designers is how to texture a 3D object with realistic-looking surface characteristics that react to various lighting conditions in a manner similar to the surface of an actual object having, for example, random surface flaws, irregularities, roughness, bumps or other slight non-planar surface variations. Regular texture mapping does not provide such realism because texture images are generally two-dimensional and can not react or change in appearance in response to changes in position or direction of the lighting within a rendered scene. While in some instances such minute surface characteristics might be actually modeled, the time required for translating and rendering a 3D object with such a complex surface would be prohibitive for most real-time or interactive gaming applications. Consequently, various solutions to this problem were offered. For example, a technique generally known as xe2x80x9cbump-mappingxe2x80x9d was developed which allowed one to approximate the effect that non-planar surface variations would produce on lighted object. See, for example, J. F. Blinn xe2x80x9cSimulation of Wrinkled Surfacesxe2x80x9d Computer Graphics, (SIGRAPH xe2x80x278 Proceedings), vol. 12, No. 3, pp. 286-292 (August 1978) and xe2x80x9cModels of Light Reflection for Computer Synthesized Picturesxe2x80x9d, Proc. 4th Conference on Computer Graphics and Instructive Techniques, 1977.
Basically, bump-mapping allows a graphics application programmer to add realism to the surface of an object without using a lot of geometry by modeling small surface variations as height differences and then applying those difference values over a surface as perturbations to a surface Normal vector used in computing surface lighting effects. Effectively, a bump-map modifies the shading of a polygon (or primitive) by perturbing the surface Normal on a per-pixel basis. The shading makes the surface appear bumpy, even though the underlying geometry is relatively flat.
Although conventional bump-mapping techniques offer some improvement, a further problem confronting graphics system designers is that conventional approaches to simple forms of bump-mapping, such as the xe2x80x9cembossxe2x80x9d-style of bump mapping, typically only consider the interaction between a bump map and a single diffuse light source. Moreover, in many cases, the bump map is inconveniently xe2x80x9ctiedxe2x80x9d to a specific geometric shape in the sense that it should be constructed (i.e., parameterized) for an object having a particular surface geometry and only works well for geometrically similar surfaces. In addition, if the object is rotated, the bump map will not apply to the entire surface (e.g., newly visible surface regions after rotation).
Another known technique for providing realistic looking surface on a rendered object uses a method called xe2x80x9cenvironment mappingxe2x80x9d. Environment mapping (EM), also called xe2x80x9creflection mappingxe2x80x9d, is a simple yet powerful method of generating approximations of reflections in curved surfaces. This technique was introduced by Blinn and Newell, xe2x80x9cTexture and Reflection In Computer Generated Images,xe2x80x9d Communications of the ACM. Vol. 19, no. 10, pp. 542-547 (October 1976). Conventionally, methods start with a ray from the viewer to a point on the reflector. This ray is then reflected with respect to the normal at that point. Instead of finding the intersection with the closest surface, as is done in ray tracing processes, EM uses the direction of the reflection vector as an index to an image containing the environment. The environment mapping approximation assumes that the objects and lights being reflected with EM are far away, and that the reflector will not reflect itself. If these assumptions hold, then the environment around the reflector can be treated as a two-dimensional projection surrounding it.
The basic steps for environment mapping are as follows:
Generate a two-dimensional image of the environment (this is the environmental map).
For each pixel that contains a reflective object, compute the normal at the location on the surface of the object (if per-pixel EM is not available, then the normal is computed at polygon vertices).
Compute the reflection vector from the view vector and the normal.
Use the reflection vector to compute an index into the environment map that represents the objects in the reflection direction.
Use the data from the environment map to color the current pixel.
In addition, there are a variety of known xe2x80x9cprojectorxe2x80x9d functions that may be used to map the reflection vector into one or more textures. Blinn and Newell""s algorithm and Grene""s cubic environment mapping technique are classic mapping methods, although a sphere map is also commonly used.
While much work has been done in the past, further improvements are possible and desirable.
The present invention improves on prior techniques by providing an apparatus and example procedures for performing an environment-mapped bump-mapping (EMBM). In accordance with one aspect provided by this invention, environment mapped bump mapping in a graphics system is performed by generating texture coordinates from parameters of a surface; bump mapping to perturb the texture coordinates; environment mapping based on the perturbed texture coordinates; and displaying an image obtained from the environment mapping. The bump mapping may model surface perturbations using a three-dimensional model in modeling space, or it may model the surface perturbations in two dimensions in eye-space. These different modeling techniques provide different advantages and features.
In more detail, one environment mapped bump mapping technique uses a bump map to model surface perturbations in three dimensions. The output of the bump mapping operation is provided to a matrix multiplication operation that allows rotation in any direction. The resulting rotated values are combined with Normal vector values for environment mapping.
In another embodiment, the bump map models surface perturbations in two dimensions using partial derivatives. The bump map output is combined with Normal vector partial derivatives using a sum-of-product calculation to provide texture coordinates for environment mapping. The inverse of the transformation matrix is used for geometric transformations to transform the Normal vector partial derivatives.
In more detail, a first example EMBM procedure is provided that permits very fast processing of object surface Normal perturbations modeled in 3D (dXdYdZ) for specific object surface geometries using a pre-computed bump map stored in memory as a texture. A second example EMBM procedure is provided for Normal perturbations modeled with respect to a flat surface (dSdT) which frees the bump map from use with a particular surface geometry and allows it to be applied with environment mapping/lighting to a variety of different rendered object shapes.
The EMBM method provided by an aspect of the present invention uses a pre-constructed bump-map texture accessed as an indirect texture along with pre-computed computed object surface normals (i.e., the Normal, Tangent and Binormal vectors) from each vertex of rendered polygons to effectively generate a new perturbed Normal vector per vertex. The new perturbed Normal vectors are then used to look up an environment texture map. For example, the environment texture map may be a spherical reflection map of an environment surrounding a rendered object or a texture map containing lighting or other data for creating more complex surface lighting effects.
The example embodiment provides a specialized texture data/coordinate processing xe2x80x9cbump unitxe2x80x9d in the graphics pipeline for performing predetermined matrix multiplication operations (e.g., modeling-space to eye-space conversions) on retrieved lookup data from the indirect-texture bump map. The bump unit (e.g., see FIG. 15) uses a programmable 3xc3x972 element multiplication matrix (M) and scaling circuits that also permits rotation of bump-mapped objects about multiple orthogonal axes. The bump unit is also provided with an output storage buffer (530) for reusing computed coordinate data output values in subsequent processing cycles.
In accordance with a further aspect provided by the invention, object surface Normal perturbations for one or more specific surface geometries are modeled in 3D using a pre-computed dXdYdZ bump map stored in memory as a texture prior to running a particular graphics application (i.e., texel values within an individual bump-map specify surface Normal vector offsets per vertex in 3D model space). A texturing pipeline implemented in hardware then performs an environment-mapped bump-mapped dXdYdZ texture lookup. In the disclosed example embodiment, this is implemented using an indirect texture look-up to obtain the dXdYdZ bump map data to compute a perturbed texture coordinate for lookup into, for example, a spherical reflection environment map. At runtime, the graphics application matches an object having a particular surface geometry with the pre-computed dXdYdZ bump-map texture for that geometry and accesses the bump-map as an xe2x80x9cindirectxe2x80x9d texture.
A programmable 3xc3x972 multiplication matrix can be implemented by bump unit hardware to provide improved versatility when rendering and displaying such dXdYdZ bump-mapped objects. For example, the matrix may be programmably loaded with appropriate transform constants for allowing conversion of texture coordinate components to eye-space or dynamically loaded with texture coordinates for implementing dXdYdZ bump-mapped texturing while rotating an object about two or more orthogonal axes. The dXdYdZ bump-map indirect look-up data is then used along with per vertex Normal-generated texture coordinate components to compute the perturbed texture coordinates for the look-up into an environment map.
Although the dXdYdZ bump-map textures are custom parameterized for individual surface geometries and, consequently, are effectively xe2x80x9ctiedxe2x80x9d to the particular object for which they were designed, this approach to EMBM is advantageous in that processing is very fast, requiring only a single texture coordinate processing stage corresponding to a single shading/color-blending stage. Moreover, in a preferred implementation of the present invention, the bump-mapped objects may be dynamically rotated about at least two orthogonal axes without disruption to the bump-mapped effect on the object surface.
In accordance with another aspect provided by the invention, object surface Normal perturbations are initially modeled with respect to a flat surface, then during application runtime, the Normal perturbations may be mapped to a rendered object surface having a different or arbitrary geometric configuration. A pre-computed bump dSdT map containing partial derivative data is stored in memory as a 2D texture and subsequently accessed as an xe2x80x9cindirectxe2x80x9d texture. The pre-computed dSdT bump map data may be derived, for example, by forward differencing the data from a conventional paint program 2D or other image. Basically, Normal, Tangent and Binormal vectors, which are specified per vertex as polygon vertex attributes of a modeled 3D object surface, are first rotated (transformed) into view-space (eye-space/camera-space) and then used along with the precomputed bump map data to compute a perturbed Normal for each vertex. The perturbed Normal is then used to look up a light or environment map. In other words, Binormal- and Tangent-generated texture coordinate components are scaled (multiplied) by the pre-computed partial derivative dSdT bump map data (stored as an indirect texture) and then are combined with Normal vector generated texture coordinate components over several cycles/stages. The resulting computed texture coordinates correspond to an appropriately perturbed Normal vector, which is then used to look-up a light or environment map.